﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Model;
using BLL;

namespace TaoBaoProject.Handlers.QQRelateHandler
{
  /// <summary>
  /// Summary description for UpdateQQRelateHandler
  /// </summary>
  public class UpdateQQRelateHandler : IHttpHandler
  {
    QQRelationBLL qqrelationBLL = new QQRelationBLL();
    QQRelation qqrelationModel = new QQRelation();
    public void ProcessRequest(HttpContext context)
    {
      context.Response.ContentType = "text/plain";
      qqrelationModel.MainQQ = context.Request["MainQQ"];
      qqrelationModel.QQ = context.Request["QQ"];
      qqrelationModel.QQMappID = Convert.ToInt32(context.Request.QueryString["id"]);
      DateTime result;
      bool isOK = DateTime.TryParse(context.Request["CreateTime"], out result);
      if (isOK)
      {
        DateTime dt = Convert.ToDateTime(context.Request["CreateTime"]);
        qqrelationModel.CreateTime = dt.ToString();
      }
      else
      {
        qqrelationModel.CreateTime = DateTime.Now.ToString();
      }
      qqrelationBLL.UpdateQQRelation(qqrelationModel);
      string returnValue = "{MainQQ:'" + qqrelationModel.MainQQ + "',QQ:'" + qqrelationModel.QQ + "',CreateTime:'" + qqrelationModel.CreateTime + "'}";
      context.Response.Write(returnValue);
    }

    public bool IsReusable
    {
      get
      {
        return false;
      }
    }
  }
}